package com.zzf.concurrent.example.design.pattern.read.writer;

import com.zzf.concurrent.example.util.TimeUtil;
import lombok.extern.slf4j.Slf4j;

/**
 * @author GaoFeng2017
 * @date 2019/9/7 10:32
 */
@Slf4j
public class ReaderWorker extends Thread {

    private ShareData shareData;

    public ReaderWorker(ShareData shareData) {
        this.shareData = shareData;
    }

    public void read() {
        char[] read = this.shareData.read();
        log.info("reader read result is {}", new String(read));
    }

    @Override
    public void run() {
        while (true) {
            this.read();
            TimeUtil.sleep(50L);
        }
    }
}
